package com.sdry.approval.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sdry.approval.constant.ApprovalTypeEnum;
import com.sdry.approval.entity.MeSponsor;
import com.sdry.approval.mapper.MeSponsorMapper;
import com.sdry.untils.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: info_sdry
 * @description: 发起审批
 * @author: cb
 * @create: 2020-02-24 08:11
 **/
@Service
@Transactional(rollbackFor = Exception.class)
public class MeSponsorServiceImpl extends ServiceImpl<MeSponsorMapper, MeSponsor> implements MeSponsorService {

    @Autowired
    private MeSponsorMapper meSponsorMapper;

    @Override
    public void addMeSponsor(String Type,Long requestId) {
        MeSponsor meSponsor = new MeSponsor();
        meSponsor.setMeSponsorType(Type);
        meSponsor.setCompleteStatus(ApprovalTypeEnum.TYPE_APPROVAL_TJ.getCode());
        meSponsor.setUserId(UserContext.getSessionUserIdByServiceImpl());
        meSponsor.setRequestId(requestId);
        meSponsorMapper.insert(meSponsor);
    }

    @Override
    public Integer updateMeSponor(String requertType, Long requestId, String status) {
        return meSponsorMapper.updateMeSponor(requertType,requestId,status);
    }

    @Override
    public List<MeSponsor> queryCopySponsorPage() {
        return meSponsorMapper.queryCopySponsorPage();
    }
}
